<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Prepares for a search</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.yaz-schema.html">yaz_schema</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.yaz-set-option.html">yaz_set_option</a></div>
 <div class="up"><a href="ref.yaz.html">YAZ 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.yaz-search" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">yaz_search</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PECL yaz &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">yaz_search</span> &mdash; <span class="dc-title">Prepares for a search</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.yaz-search-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>yaz_search</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$id</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$type</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
   )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>yaz_search()</strong></span> prepares for a search on the given 
   connection.
  </p>
  <p class="para">
   Like <span class="function"><a href="function.yaz-connect.html" class="function">yaz_connect()</a></span> this function is non-blocking and
   only prepares for a search to be executed later when 
   <span class="function"><a href="function.yaz-wait.html" class="function">yaz_wait()</a></span> is called.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.yaz-search-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">id</code></em></dt>

     <dd>

      <p class="para">
       The connection resource returned by <span class="function"><a href="function.yaz-connect.html" class="function">yaz_connect()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">type</code></em></dt>

     <dd>

      <p class="para">
       This parameter represents the query type - only <em>&quot;rpn&quot;</em>
       is supported now in which case the third argument specifies a Type-1 
       query in prefix query notation. 
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">query</code></em></dt>

     <dd>

      <p class="para">
       The RPN query is a textual representation of the Type-1 query as
       defined by the Z39.50 standard. However, in the text representation
       as used by YAZ a prefix notation is used, that is the operator
       precedes the operands. The query string is a sequence of tokens where
       white space is ignored unless surrounded by double quotes. Tokens beginning
       with an at-character (<em>@</em>) are considered operators,
       otherwise they are treated as search terms.
      </p>
      <table class="doctable table">
       <caption><strong>RPN Operators</strong></caption>
       
        <col width="1*" />
        <col width="2*" />
        <thead>
         <tr>
          <th>Construct</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td><em>@and</em> query1 query2</td>
          <td>intersection of query1 and query2</td>
         </tr>

         <tr>
          <td><em>@or</em> query1 query2</td>
          <td>union of query1 and query2</td>
         </tr>

         <tr>
          <td><em>@not</em> query1 query2</td>
          <td>query1 and not query2</td>
         </tr>

         <tr>
          <td><em>@set</em> name</td>
          <td>result set reference</td>
         </tr>

         <tr>
          <td><em>@attrset</em> set query</td>
          <td>
           specifies attribute-set for query. This construction is only allowed
           once - in the beginning of the whole query
          </td>
         </tr>

         <tr>
          <td><em>@attr</em> [set] type=value query</td>
          <td>
           applies attribute to query. The type and value are integers 
           specifying the attribute-type and attribute-value respectively. 
           The set, if given, specifies the attribute-set.
          </td>
         </tr>

        </tbody>
       
      </table>
     
      <p class="para">
       You can find information about attributes at the 
       <a href="http://www.loc.gov/z3950/agency/defns/bib1.html" class="link external">&raquo;&nbsp;Z39.50 Maintenance Agency</a>
       site.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        If you would like to use a more friendly notation,
        use the CCL parser - functions <span class="function"><a href="function.yaz-ccl-conf.html" class="function">yaz_ccl_conf()</a></span> and 
        <span class="function"><a href="function.yaz-ccl-parse.html" class="function">yaz_ccl_parse()</a></span>.
       </p>
      </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.yaz-search-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.yaz-search-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4587">
   <p><strong>Example #1 Query Examples</strong></p>
   <div class="example-contents"><p>
    You can search for simple terms, like this:
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">computer</pre>
</div>
    </div>
    which matches documents where &quot;computer&quot; occur. No attributes are 
    specified.
   </p></div>
   <div class="example-contents"><p>
    The query 
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">&quot;knuth donald&quot;</pre>
</div>
    </div>
    matches documents where &quot;knuth donald&quot; occur (provided that the
    server supports phrase search).
   </p></div>
   <div class="example-contents"><p>
    This query applies two attributes for the same phrase.
    <div class="example-contents screen">@attr 1=1003 @attr 4=1 &quot;knuth donald&quot;</div>
    First attribute is type 1 (Bib-1 use), attribute value is 1003
    (Author).
    Second attribute has is type 4 (structure), value 1 (phrase),
    so this should match documents where Donald Knuth is author.
   </p></div>
   <div class="example-contents"><p>
    The query
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">@and @or a b @not @or c d e</pre>
</div>
    </div>
    would in infix notation look like <em>(a or b) and ((c or d) not 
    e)</em>.
   </p></div>
   <div class="example-contents"><p>
    Another, more complex, one:
    <div class="example-contents screen">
<div class="cdata"><pre>
@attrset gils @and @attr 1=4 art @attr 1=2000 company
</pre></div>
    </div>
    The query as a whole uses the GILS attributeset. The query matches
    documents where <em>art</em> occur in the title (GILS,BIB-1)
    and in which <em>company</em> occur as Distributor (GILS).
   </p></div>
  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.yaz-schema.html">yaz_schema</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.yaz-set-option.html">yaz_set_option</a></div>
 <div class="up"><a href="ref.yaz.html">YAZ 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
